/**
 * Created by aesop on 2015/4/19.
 */

var qr_code = document.getElementById("qrCode");
var qr_suggest = document.getElementById("qrSuggest");
var state_code = qr_code.getAttribute('data-state');

qr_code.onmouseover = function(){
    qr_suggest.className = "nova-note-index-operate-suggest";
}

qr_code.onmouseout = function(){
    qr_suggest.className += " hidden";
}



var xmlhttp;
function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Opera, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null) {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);

  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
    if(xmlhttp.status != 200){
      loadXMLDoc(url);
  }
  else{
      try{
          var obj = JSON.parse(xmlhttp.responseText);
          if(obj.err_code == 0){
              location.href ="/note/history"
          }
          else{
               loadXMLDoc(url)
          }
      }
      catch (e){
          loadXMLDoc(url)
      }
  }
  }
}

var url="/note/login/waiting?state=" + state_code;
window.onload = function(){
    loadXMLDoc(url);
}
